import android.support.annotation.IntDef;

/**
 * Created by wangxingsheng on 2020/7/10.
 */
public class FlagTest {

    @IntDef({
            Direction.LAYOUT_DIRECTION_RIGHT,
            Direction.LAYOUT_DIRECTION_UP_RIGHT,
            Direction.LAYOUT_DIRECTION_UP,
            Direction.LAYOUT_DIRECTION_UP_LEFT,
            Direction.LAYOUT_DIRECTION_LEFT,
            Direction.LAYOUT_DIRECTION_DOWN_LEFT,
            Direction.LAYOUT_DIRECTION_DOWN,
            Direction.LAYOUT_DIRECTION_DOWN_RIGHT,
    })
    public @interface Direction {
        int LAYOUT_DIRECTION_UP = 1;
        int LAYOUT_DIRECTION_DOWN = 1 << 1;
        int LAYOUT_DIRECTION_LEFT = 1 << 2;
        int LAYOUT_DIRECTION_RIGHT = 1 << 3;

        int LAYOUT_DIRECTION_UP_RIGHT = LAYOUT_DIRECTION_UP | LAYOUT_DIRECTION_RIGHT;
        int LAYOUT_DIRECTION_UP_LEFT = LAYOUT_DIRECTION_UP | LAYOUT_DIRECTION_LEFT;
        int LAYOUT_DIRECTION_DOWN_LEFT = LAYOUT_DIRECTION_DOWN | LAYOUT_DIRECTION_RIGHT;
        int LAYOUT_DIRECTION_DOWN_RIGHT = LAYOUT_DIRECTION_DOWN | LAYOUT_DIRECTION_LEFT;
    }

    public static void main(String[] args) {

        System.out.println(Direction.LAYOUT_DIRECTION_UP);
        System.out.println(Direction.LAYOUT_DIRECTION_DOWN);
        System.out.println(Direction.LAYOUT_DIRECTION_LEFT);
        System.out.println(Direction.LAYOUT_DIRECTION_RIGHT);
        System.out.println(Direction.LAYOUT_DIRECTION_UP_RIGHT);
        System.out.println(Direction.LAYOUT_DIRECTION_UP_LEFT);
        System.out.println(Direction.LAYOUT_DIRECTION_DOWN_LEFT);
        System.out.println(Direction.LAYOUT_DIRECTION_DOWN_RIGHT);


        System.out.println((Direction.LAYOUT_DIRECTION_DOWN_RIGHT & Direction.LAYOUT_DIRECTION_DOWN) != 0);
        System.out.println((Direction.LAYOUT_DIRECTION_DOWN_RIGHT & Direction.LAYOUT_DIRECTION_LEFT) != 0);
        System.out.println((Direction.LAYOUT_DIRECTION_DOWN_RIGHT & Direction.LAYOUT_DIRECTION_RIGHT) != 0);
        System.out.println((Direction.LAYOUT_DIRECTION_DOWN_RIGHT & Direction.LAYOUT_DIRECTION_UP) != 0);
        System.out.println((Direction.LAYOUT_DIRECTION_UP & Direction.LAYOUT_DIRECTION_UP) != 0);
    }
}
